﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyFrameWork.Dam;
using System.Data;
using MvcApplication5.Models;
using System.Data.Common;

namespace MvcApplication5.DAM
{
    public class AdminDAM : DataDAM
    {
        public AdminDAM()
        {
            this.CreateDataBase("MAINDB");
        }
        public int InsertUserData(UserModel model)
        {
            return this.InsertData("TB_employee", "id", model, null);
        }
        public DataSet SelectData(UserModel model, DBManager dbManager = null)
        {
            #region 手写SQL
            string sqlString = string.Format(@"
                            SELECT
                               TB_employee.*,
                               TB_position.position_name
                            FROM
                                TB_employee INNER JOIN TB_position 
                            ON  TB_employee.position_id=TB_position.position_id
                            WHERE
                                employee_code = @employee_code AND employee_password = @employee_password
                        ");
            DbCommand command = GetSqlStringCommand(sqlString);

            //パラメータセット
            AddInParameter(command, "@employee_code", DbType.String, model.employee_code);
            AddInParameter(command, "@employee_password", DbType.String, model.employee_password);

            //SQL文を実行する
            return ExecuteDataSet(command, dbManager);
            #endregion
        }
    }
}